package com.woniuxy.oldmanapi.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.woniuxy.oldmanapi.entity.Life;
import com.woniuxy.oldmanapi.mapper.LifeMapper;
import com.woniuxy.oldmanapi.yvo.ContractVo;
import com.woniuxy.oldmanapi.yvo.LifeVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class LifeService {
    @Autowired
    LifeMapper lifeMapper;
    public PageInfo<LifeVo> initSelectAllByCons(String name, int now, int size) {
        PageHelper.startPage(now,size);
        List<LifeVo> arr = lifeMapper.initSelectAllByCons(name);
        return new PageInfo<>(arr);
    }

    public void deleteLife(int id) {
        lifeMapper.deleteByPrimaryKey(id);
    }

    public void addContract(Life life) {
        lifeMapper.insert(life);
    }

    public LifeVo selectLifeById(int id) {
        return lifeMapper.selectLifeById(id);
    }

    public void modifyLife(Life life) {
        lifeMapper.updateByPrimaryKey(life);
    }
}
